<template>
  <div id="mainRe">
    <el-table :data="tableData" :stripe="true" style="width: 100%">
      <el-table-column label="开始时间" align="center">
        <template slot-scope="scope">{{scope.row.startTime | timeFn}}</template>
      </el-table-column>
      <el-table-column label="结束时间" align="center">
        <template slot-scope="scope">{{scope.row.endTime | timeFn}}</template>
      </el-table-column>
      <el-table-column prop="id" label="装备编号" align="center">
      </el-table-column>
      <el-table-column prop="desc" label="故障描述" align="center">
      </el-table-column>
      <!-- <el-table-column label="操作" align="center">
        <i class="el-icon-view" style="color:#67C23A;font-size:20px;"></i>
      </el-table-column> -->
    </el-table>
    <div class="footer">
      <el-pagination
        layout="prev, pager, next"
        @current-change="pageBtn"
        :page-size="count"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      page: 1,
      count: 5,
      total: 10,
      tableData: [],
    };
  },
  filters:{
    timeFn:function(v){
      let date=new Date(v);
      return date.getFullYear()+'/'+[(date.getMonth()+1)<10?'0'+(date.getMonth()+1):(date.getMonth()+1)]+'/'+[date.getDate()<10?'0'+date.getDate():date.getDate()]
    },
  },
  methods: {
    render: function () {
      this.$axios({
        url: "/equipment/list/maintenancerecords",
        params: {
          limit: this.count,
          page: this.page,
        },
      }).then(({ data }) => {
        // console.log(data);
        if (data.code == 0) {
          this.tableData = data.data;
          this.total = data.total;
        } else {
          this.$message.error("数据加载失败!");
        }
      });
    },
    pageBtn: function (v) {
      this.page = v;
      this.render();
    },
  },
  mounted: function () {
    this.render();
  },
};
</script>

<style scoped lang="less">
#mainRe {
  padding-bottom: 50px;
}
.footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
}
</style>